package com.sgcc.sx.pmos.e_sx_home.activity;


import android.graphics.Color;
import android.text.TextUtils;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.bigkoo.pickerview.listener.OnTimeSelectListener;
import com.blankj.utilcode.util.TimeUtils;
import com.github.mikephil.charting.charts.BarLineChartBase;
import com.github.mikephil.charting.charts.CombinedChart;
import com.github.mikephil.charting.charts.LineChart;
import com.github.mikephil.charting.components.Legend;
import com.github.mikephil.charting.components.XAxis;
import com.github.mikephil.charting.components.YAxis;
import com.github.mikephil.charting.formatter.IndexAxisValueFormatter;
import com.lxj.xpopup.XPopup;
import com.sgcc.sx.pmos.arouter.home.HomeArouterPath;
import com.sgcc.sx.pmos.common.base.MvpBaseActivity;
import com.sgcc.sx.pmos.common.bean.QueryPriceTrendBean;
import com.sgcc.sx.pmos.common.utils.BigDecimalUtils;
import com.sgcc.sx.pmos.common.utils.DateUtils;
import com.sgcc.sx.pmos.common.utils.DialogUtil;
import com.sgcc.sx.pmos.common.view.LineMarkerView1;
import com.sgcc.ln.pmos.common.widget.TitleBar;
import com.sgcc.pmos.nativesdk.R;
import com.sgcc.sx.pmos.e_sx_home.adapter.MarketListAdapter;
import com.sgcc.sx.pmos.e_sx_home.adapter.MarketSituationChartAdapter;
import com.sgcc.sx.pmos.e_sx_home.bean.MarketSituationBean;
import com.sgcc.sx.pmos.e_sx_home.bean.NoTimeDivisionPriceTrendBean;
import com.sgcc.sx.pmos.e_sx_home.bean.TimeDivisionPriceTrendBean;
import com.sgcc.sx.pmos.e_sx_home.contract.MarketSituationContract;
import com.sgcc.sx.pmos.e_sx_home.dialog.DateSelectDialog;
import com.sgcc.sx.pmos.e_sx_home.presenter.MarketSituationPresenter;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.List;

/**
 * @author ChaoAJ
 * @describe 市场行情
 * @time 2022/9/13 14:27
 */

@Route(path = HomeArouterPath.HOME_MARKET_SITUATION)
public class MarketSituationActivity extends MvpBaseActivity<MarketSituationPresenter> implements MarketSituationContract.View {


    private TitleBar tbTitle;
    private TextView tvRetail;
    private TextView tvMonthText1;
    private TextView tvMonthText2;
    private ProgressBar pbRetail;
    private TextView tvWholesale;
    private ProgressBar pbWholesale;
    private LineChart lineChart1;
    private TextView tvDate1;
    private CombinedChart combinedChart2;
    private RecyclerView rvDataList;
    private TextView tvDate2;
    private LineChart lineChart3;
    private RadioGroup rgDate;
    private RadioButton rbDate6;
    private RadioButton rbDate12;
    private RadioGroup rgDate0;
    private RadioButton rbDate06;
    private RadioButton rbDate012;
    private LineChart lineChart4;
    private RadioGroup rgDate1;
    private RadioButton rbDate61;
    private RadioButton rbDate121;
    private LineChart lineChart5;
    private MarketSituationBean marketSituationBean;

    private LinearLayout linner_page_1, linner_page_2;
    private LinearLayout linner_table1, linner_table2;
    private TextView table_txt1, table_txt2;
    private View btm_lin1, btm_lin2;

    private MarketSituationChartAdapter marketSituationChartAdapter;
    private MarketListAdapter scjgls_adapter1, scjgls_adapter2, scjgls_adapter3;
    private RecyclerView scjgls_list1, scjgls_list2, scjgls_list3;

    private MarketListAdapter fsjgfdxls_adapter1, fsjgfdxls_adapter2, fsjgfdxls_adapter3, fsjgfdxls_adapter4;
    private RecyclerView fsjgfdxls_list1, fsjgfdxls_list2, fsjgfdxls_list3, fsjgfdxls_list4;
    private List<String> timeList = new ArrayList<>();
    private TextView page2_tvDate2;

    private MarketListAdapter bfsjgfdxls_adapter1, bfsjgfdxls_adapter2, bfsjgfdxls_adapter3;
    private RecyclerView bfsjgfdxls_list1,bfsjgfdxls_list2,bfsjgfdxls_list3;

    @Override
    protected int getContentViewLayoutID() {
        return R.layout.activity_market_situation;
    }

    @Override
    protected void initViews() {
        super.initViews();

        tbTitle = findViewById(R.id.tbTitle);
        tvMonthText1 = findViewById(R.id.tvMonthText1);
        tvMonthText2 = findViewById(R.id.tvMonthText2);
        tvRetail = findViewById(R.id.tvRetail);
        pbRetail = findViewById(R.id.pbRetail);
        tvWholesale = findViewById(R.id.tvWholesale);
        pbWholesale = findViewById(R.id.pbWholesale);
        lineChart1 = findViewById(R.id.lineChart1);
        tvDate1 = findViewById(R.id.tvDate1);
        combinedChart2 = findViewById(R.id.combinedChart2);
        rvDataList = findViewById(R.id.rvDataList);
        tvDate2 = findViewById(R.id.tvDate2);
        lineChart3 = findViewById(R.id.lineChart3);
        rgDate = findViewById(R.id.rg_date);
        rbDate6 = findViewById(R.id.rb_date6);
        rbDate12 = findViewById(R.id.rb_date12);
        rgDate0 = findViewById(R.id.rg_date0);
        rbDate06 = findViewById(R.id.rb_date06);
        rbDate012 = findViewById(R.id.rb_date012);
        lineChart4 = findViewById(R.id.lineChart4);
        rgDate1 = findViewById(R.id.rg_date1);
        rbDate61 = findViewById(R.id.rb_date61);
        rbDate121 = findViewById(R.id.rb_date121);
        lineChart5 = findViewById(R.id.lineChart5);

        //新修改标签切换页面部分组件实例化


        linner_page_1 = findViewById(R.id.linner_page_1);
        linner_page_2 = findViewById(R.id.linner_page_2);
        linner_table1 = findViewById(R.id.linner_table1);
        linner_table2 = findViewById(R.id.linner_table2);
        table_txt1 = findViewById(R.id.table_txt1);
        table_txt2 = findViewById(R.id.table_txt2);
        btm_lin1 = findViewById(R.id.btm_lin1);
        btm_lin2 = findViewById(R.id.btm_lin2);
        linner_table1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                onTableChange(1);
            }
        });
        linner_table2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                onTableChange(2);
            }
        });

        //市场价格历史参考值列表初始化 3组
        scjgls_list1 = findViewById(R.id.scjgls_list1);
        scjgls_adapter1 = new MarketListAdapter(this);
        scjgls_list1.setLayoutManager(new LinearLayoutManager(this));
        scjgls_list1.setAdapter(scjgls_adapter1);

        scjgls_list2 = findViewById(R.id.scjgls_list2);
        scjgls_adapter2 = new MarketListAdapter(this);
        scjgls_list2.setLayoutManager(new LinearLayoutManager(this));
        scjgls_list2.setAdapter(scjgls_adapter2);

        scjgls_list3 = findViewById(R.id.scjgls_list3);
        scjgls_adapter3 = new MarketListAdapter(this);
        scjgls_list3.setLayoutManager(new LinearLayoutManager(this));
        scjgls_list3.setAdapter(scjgls_adapter3);

        //分时价格浮动项历史参考值 4组
        fsjgfdxls_list1 = findViewById(R.id.fsjgfdxls_list1);
        fsjgfdxls_adapter1 = new MarketListAdapter(this);
        fsjgfdxls_list1.setLayoutManager(new LinearLayoutManager(this));
        fsjgfdxls_list1.setAdapter(fsjgfdxls_adapter1);

        fsjgfdxls_list2 = findViewById(R.id.fsjgfdxls_list2);
        fsjgfdxls_adapter2 = new MarketListAdapter(this);
        fsjgfdxls_list2.setLayoutManager(new LinearLayoutManager(this));
        fsjgfdxls_list2.setAdapter(fsjgfdxls_adapter2);

        fsjgfdxls_list3 = findViewById(R.id.fsjgfdxls_list3);
        fsjgfdxls_adapter3 = new MarketListAdapter(this);
        fsjgfdxls_list3.setLayoutManager(new LinearLayoutManager(this));
        fsjgfdxls_list3.setAdapter(fsjgfdxls_adapter3);

        fsjgfdxls_list4 = findViewById(R.id.fsjgfdxls_list4);
        fsjgfdxls_adapter4 = new MarketListAdapter(this);
        fsjgfdxls_list4.setLayoutManager(new LinearLayoutManager(this));
        fsjgfdxls_list4.setAdapter(fsjgfdxls_adapter4);
        initTimeList();
        page2_tvDate2=findViewById(R.id.page2_tvDate2);


        //不分时价格浮动项历史参考值 3组
        bfsjgfdxls_list1 = findViewById(R.id.bfsjgfdxls_list1);
        bfsjgfdxls_adapter1 = new MarketListAdapter(this);
        bfsjgfdxls_list1.setLayoutManager(new LinearLayoutManager(this));
        bfsjgfdxls_list1.setAdapter(bfsjgfdxls_adapter1);

        bfsjgfdxls_list2 = findViewById(R.id.bfsjgfdxls_list2);
        bfsjgfdxls_adapter2 = new MarketListAdapter(this);
        bfsjgfdxls_list2.setLayoutManager(new LinearLayoutManager(this));
        bfsjgfdxls_list2.setAdapter(bfsjgfdxls_adapter2);

        bfsjgfdxls_list3 = findViewById(R.id.bfsjgfdxls_list3);
        bfsjgfdxls_adapter3 = new MarketListAdapter(this);
        bfsjgfdxls_list3.setLayoutManager(new LinearLayoutManager(this));
        bfsjgfdxls_list3.setAdapter(bfsjgfdxls_adapter3);


    }

    private void initTimeList() {
        timeList.clear();
        for (int i = 1; i < 25; i++) {
            timeList.add(i + "");
        }
    }

    private void onTableChange(int pageNum) {
        if (pageNum == 1) {
            linner_page_1.setVisibility(View.VISIBLE);
            linner_page_2.setVisibility(View.GONE);
            table_txt1.setTextColor(0xff0092FF);
            table_txt2.setTextColor(0xff555555);
            btm_lin1.setVisibility(View.VISIBLE);
            btm_lin2.setVisibility(View.INVISIBLE);
        } else {
            linner_page_2.setVisibility(View.VISIBLE);
            linner_page_1.setVisibility(View.GONE);
            table_txt2.setTextColor(0xff0092FF);
            table_txt1.setTextColor(0xff555555);
            btm_lin2.setVisibility(View.VISIBLE);
            btm_lin1.setVisibility(View.INVISIBLE);
        }
    }

    @Override
    protected void initData() {
        super.initData();
        tbTitle.setTitle("市场行情");


        mPresenter.getData();
        tvDate1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String[] strings = new String[]{"2022-01", "2022-02", "2022-03", "2022-04", "2022-05", "2022-06", "2022-07"};
                showPopupDialog(strings, 0);
            }
        });
        tvDate2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String yyyy = TimeUtils.date2String(TimeUtils.getNowDate(), "yyyy");
                String mm = TimeUtils.date2String(TimeUtils.getNowDate(), "MM");

                int year = Integer.parseInt(yyyy);
                int month = Integer.parseInt(mm);


                Calendar startDate = Calendar.getInstance();
                startDate.set(2021, 7, 1);
                Calendar endDate = Calendar.getInstance();
                endDate.add(Calendar.MONTH, 1);
//                endDate.set(month == 12 ? year + 1 : year, month == 12 ? 0 : month - 1, 1);

                Calendar selectedDate = Calendar.getInstance();
                selectedDate.set(year, month - 1, 1);

                DialogUtil.showDateSelectDialog(mContext,
                        new boolean[]{true, true, false, false, false, false},
                        startDate, endDate, selectedDate, new OnTimeSelectListener() {
                            @Override
                            public void onTimeSelect(Date date, View v) {
                                String string = TimeUtils.date2String(date, "yyyy-MM");
                                tvDate2.setText(string);
                                page2_tvDate2.setText(string);
                                mPresenter.queryTimeDivisionPriceTrend(string);
                            }
                        }
                );
            }
        });

        page2_tvDate2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String yyyy = TimeUtils.date2String(TimeUtils.getNowDate(), "yyyy");
                String mm = TimeUtils.date2String(TimeUtils.getNowDate(), "MM");

                int year = Integer.parseInt(yyyy);
                int month = Integer.parseInt(mm);


                Calendar startDate = Calendar.getInstance();
                startDate.set(2021, 7, 1);
                Calendar endDate = Calendar.getInstance();
                endDate.add(Calendar.MONTH, 1);
//                endDate.set(month == 12 ? year + 1 : year, month == 12 ? 0 : month - 1, 1);

                Calendar selectedDate = Calendar.getInstance();
                selectedDate.set(year, month - 1, 1);

                DialogUtil.showDateSelectDialog(mContext,
                        new boolean[]{true, true, false, false, false, false},
                        startDate, endDate, selectedDate, new OnTimeSelectListener() {
                            @Override
                            public void onTimeSelect(Date date, View v) {
                                String string = TimeUtils.date2String(date, "yyyy-MM");
                                tvDate2.setText(string);
                                page2_tvDate2.setText(string);
                                mPresenter.queryTimeDivisionPriceTrend(string);
                            }
                        }
                );
            }
        });

        rgDate0.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup, int i) {
                if (i == R.id.rb_date06) {
//                    initChart(lineChart1, marketSituationBean.getChart1XAxis(0),
//                            false, marketSituationBean.getChart1LineData(0));
                }
                if (i == R.id.rb_date012) {
//                    initChart(lineChart1, marketSituationBean.getChart1XAxis(1),
//                            false, marketSituationBean.getChart1LineData(1));
                }

            }
        });
        rgDate.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup, int i) {
                String endTime;
                String mm = TimeUtils.date2String(TimeUtils.getNowDate(), "MM");
                if (mm.equals("12")) {
                    String yyyy = TimeUtils.date2String(TimeUtils.getNowDate(), "yyyy");
                    int year = Integer.parseInt(yyyy);
                    endTime = year + 1 + "-01";
                } else {
                    endTime = TimeUtils.millis2String(TimeUtils.getNowMills(), "yyyy-MM");
                }

                if (i == R.id.rb_date6) {
                    mPresenter.queryNoTimeDivisionPriceTrend(
                            endTime,
                            DateUtils.getMonthBackString1(-5, "yyyy-MM"));
                }
                if (i == R.id.rb_date12) {
                    mPresenter.queryNoTimeDivisionPriceTrend(
                            endTime,
                            DateUtils.getMonthBackString1(-11, "yyyy-MM"));
                }

            }
        });
        rgDate1.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup, int i) {
                if (i == R.id.rb_date61) {
                    initChart(lineChart5, marketSituationBean.getChart5XAxis(0),
                            false, marketSituationBean.getChart5LineData(0));
                }
                if (i == R.id.rb_date121) {
                    initChart(lineChart5, marketSituationBean.getChart5XAxis(1),
                            false, marketSituationBean.getChart5LineData(1));
                }

            }
        });
        String nowDate = TimeUtils.date2String(TimeUtils.getNowDate(), "yyyy-MM");
        tvDate2.setText(nowDate);
        page2_tvDate2.setText(nowDate);
        mPresenter.queryTimeDivisionPriceTrend(nowDate);


        String endTime;
        String mm = TimeUtils.date2String(TimeUtils.getNowDate(), "MM");
        if (mm.equals("12")) {
            String yyyy = TimeUtils.date2String(TimeUtils.getNowDate(), "yyyy");
            int year = Integer.parseInt(yyyy);
            endTime = year + 1 + "-01";
        } else {
            endTime = TimeUtils.millis2String(TimeUtils.getNowMills(), "yyyy-MM");
        }

        mPresenter.queryNoTimeDivisionPriceTrend(
                endTime,
                DateUtils.getMonthBackString1(-5, "yyyy-MM"));
        mPresenter.queryPriceTrend();
    }


    private void showPopupDialog(String[] strings, int type) {

        new XPopup.Builder(mContext)
                .isDestroyOnDismiss(true)
                .isViewMode(true)
                .asCustom(new DateSelectDialog(mContext, strings, new DateSelectDialog.ItemClickListener() {
                    @Override
                    public void onClick(String text, int position) {

                        if (type == 0) {
                            initChart(combinedChart2, marketSituationBean.getChart2XAxis(), true, marketSituationBean.getChart2Data());

                            tvDate1.setText(text);

                            List<MarketSituationBean.Data> dataList = marketSituationBean.getChart2List().get(position);

                            if (null != marketSituationBean.chart2BarDataList && marketSituationBean.chart2BarDataList.size() > 0 &&
                                    null != marketSituationBean.chart2LineDataList && marketSituationBean.chart2LineDataList.size() > 0) {
                                dataList.get(1).setText2(marketSituationBean.chart2BarDataList.get(0).getY() + "");
                                dataList.get(2).setText2(marketSituationBean.chart2BarDataList.get(1).getY() + "");
                                dataList.get(3).setText2(marketSituationBean.chart2BarDataList.get(2).getY() + "");

                                dataList.get(1).setText3(marketSituationBean.chart2LineDataList.get(0).getY() + "");
                                dataList.get(2).setText3(marketSituationBean.chart2LineDataList.get(1).getY() + "");
                                dataList.get(3).setText3(marketSituationBean.chart2LineDataList.get(2).getY() + "");
                            }
                            marketSituationChartAdapter.setList(dataList);
                        }


                    }
                }))
                .show();

    }


    @Override
    protected MarketSituationPresenter createPresenter() {
        return new MarketSituationPresenter();
    }


    @Override
    public void querySuccess(MarketSituationBean bean) {
        marketSituationBean = bean;

    }

    @Override
    public void queryTimeDivisionPriceTrendSuccess(TimeDivisionPriceTrendBean.DadaBean bean) {
        fsjgfdxls_adapter1.setNewData(timeList);
        List<String>ydjzList=new ArrayList<>(bean.getYdjzList());
        List<String>ydList=new ArrayList<>(bean.getYdList());
        List<String>rgdList=new ArrayList<>(bean.getRgdList());
        for(int i=0;i<timeList.size();i++){
            if(ydjzList.size()<=i){
                ydjzList.add("--");
            }
            if(ydList.size()<=i){
                ydList.add("--");
            }
            if(rgdList.size()<=i){
                rgdList.add("--");
            }
        }
        fsjgfdxls_adapter2.setNewData(ydjzList);
        fsjgfdxls_adapter3.setNewData(ydList);
        fsjgfdxls_adapter4.setNewData(rgdList);

        String minValue1 = "100";
        String minValue2 = "100";
        String minValue3 = "100";
        if (null != bean.getYdjzList() && bean.getYdjzList().size() > 0)
            minValue1 = Collections.min(bean.getYdjzList());
        if (null != bean.getYdList() && bean.getYdList().size() > 0)
            minValue2 = Collections.min(bean.getYdList());
        if (null != bean.getRgdList() && bean.getRgdList().size() > 0)
            minValue3 = Collections.min(bean.getRgdList());
        float min = 100;
        try {
            min = Math.min(Float.parseFloat(minValue1), Float.parseFloat(minValue2));
            min = Math.min(Float.parseFloat(minValue3), min);
        } catch (Exception e) {

        }

        initChart(min, lineChart3, marketSituationBean.getChart3XAxis(),
                false, MarketSituationBean.getChart3LineData(bean.getYdjzList(),
                        bean.getYdList(), bean.getRgdList()));

    }

    @Override
    public void queryNoTimeDivisionPriceTrendSuccess(NoTimeDivisionPriceTrendBean.DadaBean bean) {

        List<String> dateList = bean.getDateList();
        List<String>gwPriceList=new ArrayList<>(bean.getGwPriceList());
        List<String>ydPriceList=new ArrayList<>(bean.getYdPriceList());
        for(int i=0;i<dateList.size();i++){
            if(gwPriceList.size()<=i){
                gwPriceList.add("--");
            }
            if(ydPriceList.size()<=i){
                ydPriceList.add("--");
            }
        }
        bfsjgfdxls_adapter1.setNewData(dateList);
        bfsjgfdxls_adapter2.setNewData(gwPriceList);
        bfsjgfdxls_adapter3.setNewData(ydPriceList);

        String[] dates = dateList.toArray(new String[dateList.size()]);

        String minValue1 = Collections.min(bean.getYdPriceList());
        float min = 100;
        try {
            min = Float.parseFloat(minValue1);
        } catch (Exception e) {

        }
        initChart(min, lineChart4, true, dates, false,
                MarketSituationBean.getChart4LineData(bean.getGwPriceList(), bean.getYdPriceList()));

    }

    @Override
    public void queryPriceTrendSuccess(QueryPriceTrendBean.DadaBean bean) {
        if (null != bean) {
            if (null != bean.getDateList() && bean.getDateList().size() > 0) {
                scjgls_adapter1.setNewData(bean.getDateList());

                List<String>lsPriceList=new ArrayList<>(bean.getLsPriceList());
                List<String>pfPriceList=new ArrayList<>(bean.getPfPriceList());
                for(int i=0;i<bean.getDateList().size();i++){
                    if(lsPriceList.size()<=i){
                        lsPriceList.add("--");
                    }
                    if(pfPriceList.size()<=i){
                        pfPriceList.add("--");
                    }
                }
                scjgls_adapter2.setNewData(lsPriceList);
                scjgls_adapter3.setNewData(pfPriceList);

                List<String> dateList = bean.getDateList();
                String[] dates = dateList.toArray(new String[dateList.size()]);

                String[] split = bean.getDateList().get(bean.getDateList().size() - 1).split("-");
                tvMonthText1.setText(split[1] + "月零售均价");
                tvMonthText2.setText(split[1] + "月批发均价");

                float num = 0f;
                float num2 = 0f;
                if (null != bean.getLsPriceList() && bean.getLsPriceList().size() > 0) {
                    String s = bean.getLsPriceList().get(bean.getLsPriceList().size() - 1);
                    num = Float.parseFloat(TextUtils.isEmpty(s) ? "0" : s);
                }
                if (null != bean.getPfPriceList() && bean.getPfPriceList().size() > 0) {
                    String s = bean.getPfPriceList().get(bean.getPfPriceList().size() - 1);
                    num2 = Float.parseFloat(TextUtils.isEmpty(s) ? "0" : s);
                }
                tvRetail.setText(BigDecimalUtils.onKeep3Decimal(num + ""));
                tvWholesale.setText(BigDecimalUtils.onKeep3Decimal(num2 + ""));
                pbRetail.setMax(500);
                pbRetail.setProgress((int) num);
                pbWholesale.setMax(500);
                pbWholesale.setProgress((int) num2);

                String minValue1 = Collections.min(bean.getLsPriceList());
                String minValue2 = Collections.min(bean.getPfPriceList());
                float min = 100;
                try {
                    min = Float.parseFloat(minValue1)>Float.parseFloat(minValue2)?Float.parseFloat(minValue2):Float.parseFloat(minValue1);
                } catch (Exception e) {

                }
                initChart(min, lineChart1, true,
                        dates, false, MarketSituationBean.getChart1LineData(bean.getLsPriceList()
                                , bean.getPfPriceList()));
            }
        }

    }

    @Override
    public void queryFailed() {

    }


    private void initChart(float minValue, BarLineChartBase barLineChartBase,
                           boolean isLabelRotationAngle, String[] xAxisValue,
                           boolean isAxisRight, MarketSituationBean.BackBean bean) {


        barLineChartBase.getDescription().setEnabled(false);
        barLineChartBase.setTouchEnabled(true);
        barLineChartBase.setDragEnabled(true);
        barLineChartBase.setPinchZoom(false);
        barLineChartBase.setScaleEnabled(false);
        barLineChartBase.setDrawGridBackground(false);

        LineMarkerView1 mv = new LineMarkerView1(mContext, xAxisValue, bean.getDataList(), bean.getIndex());
        mv.setChartView(barLineChartBase);
        barLineChartBase.setMarker(mv);

        XAxis x = barLineChartBase.getXAxis();
        x.setTextColor(Color.parseColor("#999999"));
        x.setDrawGridLines(false);
        x.setDrawAxisLine(true);
        if (isLabelRotationAngle)
            x.setLabelRotationAngle(-45);
        x.setPosition(XAxis.XAxisPosition.BOTTOM);
        x.setAxisLineWidth(1);
//        //解决 柱状图 左右两边只显示了一半的问题
//        if (isCombinedChart) {
//            x.setAxisMinimum(-0.5f);
//            x.setAxisMaximum(2.5f);
//            x.setDrawLabels(false);
//        } else {
        x.setLabelCount(xAxisValue.length, true);
        x.setValueFormatter(new IndexAxisValueFormatter(xAxisValue));
        x.setDrawLabels(true);
//        }

        if (bean.getIndex() == 2) {
            x.setLabelCount(12);
            x.setValueFormatter(new IndexAxisValueFormatter(xAxisValue));
        }

        x.setAxisLineColor(Color.parseColor("#DCDCDC"));


        YAxis y = barLineChartBase.getAxisLeft();
        y.setTextColor(Color.parseColor("#999999"));
        y.setAxisMinimum(minValue);
        y.setLabelCount(6, true);
        y.setDrawAxisLine(false);
        if (isAxisRight) {
            YAxis axisRight = barLineChartBase.getAxisRight();
            axisRight.setTextColor(Color.parseColor("#999999"));
            axisRight.setLabelCount(6);
            axisRight.setAxisMinimum(0);
            axisRight.setDrawAxisLine(false);
        } else
            barLineChartBase.getAxisRight().setEnabled(false);

        Legend l = barLineChartBase.getLegend();
        l.setEnabled(false);
        barLineChartBase.setData(bean.getData());
        barLineChartBase.invalidate();

    }

    private void initChart(BarLineChartBase barLineChartBase, String[] xAxisValue,
                           boolean isAxisRight, MarketSituationBean.BackBean bean) {
        initChart(100, barLineChartBase, false, xAxisValue, isAxisRight, bean);

    }

    private void initChart(float minValue, BarLineChartBase barLineChartBase, String[] xAxisValue,
                           boolean isAxisRight, MarketSituationBean.BackBean bean) {
        initChart(minValue, barLineChartBase, false, xAxisValue, isAxisRight, bean);

    }


}